﻿#include "IdaWidgetHelper.h"

#include <QPushButton>
#include <QTableWidget>
#include <QHeaderView>
#include <QColor>

namespace BaseWidget
{
    void IdaWidgetHelper::setMainButtonStyle(QPushButton* button)
    {
        button->setStyleSheet("\
            QPushButton {\
              background-color: #3D6D99;\
              color: #FFFFFF;\
              border: 1px solid #3D6D99;\
            }\
            QPushButton:disabled {\
              background-color: #EBEDEE;\
              color: #C3C5C7;\
              border: 1px solid #DEDFE1;\
            }\
            QPushButton:hover {\
              background-color: #3D6D99;\
              color: #FFFFFF;\
              border: 1px solid #3D6D99;\
            }\
            QPushButton:pressed {\
              background-color: #3D6D99;\
              color: #FFFFFF;\
            }\
        ");

        //QPushButton:focus, \

    }

    void IdaWidgetHelper::setTableWidgetStyle(QTableWidget* tableWidget)
    {
        tableWidget->horizontalHeader()->setStyleSheet(QString(u8"QHeaderView::section{background-color: #F7F8F9; color: #292A2B; border:1px solid #DEDFE1;border-left:0px solid #DEDFE1;}"));
        tableWidget->verticalHeader()->setHidden(true);
        tableWidget->verticalHeader()->setDefaultSectionSize(24);
        tableWidget->horizontalHeader()->setFixedHeight(24);
    }

    void IdaWidgetHelper::setPushButtonSelcetBarCheckedState(QPushButton* pushButton, bool isChecked, const QColor& color)
    {
        if (isChecked)
        {
            if (color == Qt::red)
                pushButton->setStyleSheet("QPushButton { background-color: #CC2F1D; }"); // 未选中选项，用红色提示
            else if (color == Qt::blue)
                pushButton->setStyleSheet("QPushButton { background-color: #DBEFFF; }"); // 已选中选项，用蓝色提示
            else
                return;
        }
        else
        {
            pushButton->setStyleSheet("");
        }
    }

}
